@extends('Admin.layouts.application')

@section('css')

    <link rel="stylesheet" href="/assets/xSystem/vendor/webupload/dist/webuploader.css"/>
    <link rel="stylesheet" type="text/css" href="/assets/xSystem/vendor/webupload/style.css"/>
    <style>

    </style>
@endsection
@section('content')
    <div class="admin-content">
        <div class="admin-content-body">
            <div class="am-cf am-padding am-padding-bottom-0">
                <div class="am-fl am-cf">
                    <strong class="am-text-primary am-text-lg">修改视频信息</strong> /
                    <small>Modify video information</small>
                </div>
            </div>

            <hr>

            @include('Admin.layouts._flash')

            <div class="am-g">
                <div class="am-u-sm-12 am-u-md-12">


                    <form class="am-form" action="{{ route('video.update',$video->id) }}" method="post">
                        {!! csrf_field() !!}
                        {!! method_field('put') !!}
                        <div class="am-tabs am-margin" data-am-tabs>
                            <ul class="am-tabs-nav am-nav am-nav-tabs">
                                <li class="am-active"><a href="#tab1">通用信息</a></li>
                                <li><a href="#tab4">视频URL</a></li>
                            </ul>

                            <div class="am-tabs-bd" style="overflow:hidden">
                                <div class="am-tab-panel am-fade am-in am-active" id="tab1">

                                    <div class="am-g am-margin-top">
                                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                                            所属栏目
                                        </div>
                                        <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">

                                            <select data-am-selected="{btnWidth: '100%',  btnStyle: 'secondary', btnSize: 'sm', maxHeight: 360, searchBox: 1}"
                                                    name="video_category_id">

                                                @foreach($categories as $category)

                                                    <option value="{{$category->id}}"
                                                            @if($category->id == $video->video_category_id) selected @endif>
                                                        {{$category->name}}
                                                    </option>

                                                @endforeach


                                            </select>
                                        </div>
                                    </div>
                                    <div class="am-g am-margin-top">
                                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                                            所属小类
                                        </div>
                                        <div class="am-u-sm-8 am-u-md-4">
                                            <input type="text" class="am-input-sm " name="genre" value="{{$video->genre}}">
                                        </div>
                                        <div class="am-hide-sm-only am-u-md-6">*必填 例：喜剧,爱情,科幻</div>
                                    </div>

                                    <div class="am-g am-margin-top">
                                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                                            视频名称
                                        </div>
                                        <div class="am-u-sm-8 am-u-md-4">
                                            <input type="text" class="am-input-sm" name="name" value="{{$video->name}}">
                                        </div>
                                        <div class="am-hide-sm-only am-u-md-6">*必填，不可重复</div>
                                    </div>

                                    <div class="am-g am-margin-top">
                                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                                            主演
                                        </div>
                                        <div class="am-u-sm-8 am-u-md-4">
                                            <input type="text" class="am-input-sm" name="stars"
                                                   value="{{$video->stars}}">
                                        </div>
                                        <div class="am-hide-sm-only am-u-md-6">*必填</div>
                                    </div>

                                    <div class="am-g am-margin-top">
                                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                                            标题
                                        </div>
                                        <div class="am-u-sm-8 am-u-md-4">
                                            <input type="text" class="am-input-sm" name="title"
                                                   value="{{$video->title}}">
                                        </div>
                                        <div class="am-hide-sm-only am-u-md-6">*必填</div>
                                    </div>

                                    <div class="am-g am-margin-top">
                                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                                            缩略图
                                        </div>

                                        <div class="am-u-sm-8 am-u-md-8 am-u-end col-end">
                                            <div class="am-form-group am-form-file new_thumb">
                                                <button type="button" class="am-btn am-btn-secondary am-btn-sm">
                                                    <i class="am-icon-cloud-upload" id="loading"></i> 上传新的缩略图
                                                </button>
                                                <input type="file" id="thumb_upload" value="{{$video->thumb}}">
                                            </div>
                                            <input type="hidden" name="thumb" value="{{$video->thumb}}">
                                            <hr data-am-widget="divider" style="" class="am-divider am-divider-dashed"/>

                                            <div>
                                                <img src="{{$video->thumb}}" id="img_show" style="max-height: 200px;">
                                            </div>
                                        </div>
                                    </div>

                                    <div class="am-g am-margin-top sort">
                                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                                            描述信息
                                        </div>
                                        <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                                            <textarea rows="10" name="desc">{{$video->desc}}</textarea>
                                        </div>
                                    </div>

                                    <div class="am-g am-margin-top">
                                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                                            是否显示
                                        </div>
                                        <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                                            <label class="am-radio-inline">
                                                <input type="radio" value="1" name="is_show"
                                                       @if($video->is_show == 1) checked @endif> 是
                                            </label>
                                            <label class="am-radio-inline">
                                                <input type="radio" value="0" name="is_show"
                                                       @if($video->is_show == 0) checked @endif> 否
                                            </label>
                                        </div>
                                    </div>

                                    <div class="am-g am-margin-top">
                                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                                            加入推荐
                                        </div>
                                        <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                                            <div class="am-btn-group" data-am-button="">

                                                <label class="am-btn am-btn-default am-btn-xs am-round">
                                                    <input type="checkbox" name="is_top" value="1"
                                                           @if($video->is_top == 1) checked @endif> 置顶
                                                </label>
                                                <label class="am-btn am-btn-default am-btn-xs am-round">
                                                    <input type="checkbox" name="is_hot" value="1"
                                                           @if($video->is_hot == 1) checked @endif> 热门

                                                </label>
                                                <label class="am-btn am-btn-default am-btn-xs am-round">
                                                    <input type="checkbox" name="is_recommend" value="1"
                                                           @if($video->is_recommend == 1) checked @endif> 推荐
                                                </label>


                                                <label class="am-btn am-btn-default am-btn-xs am-round">
                                                    <input type="checkbox" name="is_new" value="1"
                                                           @if($video->is_new == 1) checked @endif> 新片

                                                </label>

                                            </div>
                                        </div>
                                    </div>
                                </div>

                                {{--<div class="am-tab-panel am-fade" id="tab2">
                                    <div class="am-g am-margin-top-sm">
                                        <div class="am-u-sm-12 am-u-md-12">
                                            <div id="markdown">
                                                <textarea id="editor_id" name="content"
                                                          style="height: 300px"></textarea>
                                            </div>
                                        </div>
                                    </div>

                                </div>--}}

                                <div class="am-tab-panel am-fade" id="tab4" style="overflow:scroll;height: 600px">
                                    <div class="am-g am-margin-top">
                                        <div class="am-u-sm-4 am-u-md-2 am-text-right">

                                        </div>

                                        <div class="am-u-sm-2 am-u-md-2 am-text-right">
                                            视频
                                        </div>
                                        @if($video->is_local ==0)
                                            <div class="am-u-sm-8 am-u-md-4">
                                                <div class="am-g am-margin-top" style="margin-top: 0px;">
                                                    <label style="color: red;padding-left: 20px;">每一集以换行隔开</label><br/>
                                                    <label style="color: red;padding-left: 20px;">回车后地址不能为空</label>
                                                    <label style="color: red;padding-left: 20px;">视频地址必须以http://或https://开头</label>
                                                </div>
                                            </div>
                                            @else
                                            <div class="am-u-sm-8 am-u-md-4">
                                                <div class="select_thumb">
                                                    <button type="button" class="am-btn am-btn-success am-btn-sm"
                                                            id="ck_local_upload">
                                                        <i class="am-icon-search-plus" id="loading"></i> 选择本地的视频
                                                    </button>
                                                </div>
                                            </div>

                                        @endif
                                        <div class="am-hide-sm-only am-u-md-6">*</div>
                                    </div>


                                        <div class="am-g am-margin-top">
                                            <div class="am-u-sm-2 am-u-md-2 am-text-right jishu">
                                                视频URL
                                            </div>

                                            <div class="am-u-sm-8 am-u-md-10">
                                                <textarea rows="6" style="margin-top: 0px; margin-bottom: 0px; height: 507px;" id="urls" name="urls">@foreach($video->video_url as $urls){{$urls->url."\n"}}@endforeach</textarea>
                                            </div>
                                            <div class="am-hide-sm-only am-u-md-6">

                                            </div>

                                        </div>


                                </div>
                            </div>
                        </div>

                        <div class="am-margin">
                            <button type="submit" class="am-btn am-btn-primary am-radius">提交保存</button>
                        </div>
                    </form>
                </div>
            </div>

        </div>
        @include('Admin.layouts._footer')
    </div>
@endsection

@section('js')
    <script src="/assets/xSystem/js/jquery.html5-fileupload.js"></script>
    <script src="/assets/xSystem/js/upload.js"></script>
    <script src="/assets/xSystem/vendor/ckfinder/ckfinder.js"></script>
    <script src="/assets/xSystem/js/ck_upload.js"></script>

    <script type="text/javascript" src="/assets/xSystem/vendor/webupload/dist/webuploader.js"></script>
    <script type="text/javascript" src="/assets/xSystem/vendor/webupload/upload.js"></script>

    <!-- kindeditor编辑器 -->
    <!--<script charset="utf-8" src="/assets/xSystem/vendor/kindeditor/kindeditor-all-min.js"></script>
    <script charset="utf-8" src="/assets/xSystem/vendor/kindeditor/lang/zh-CN.js"></script>
    <script>
        KindEditor.ready(function (K) {

            window.editor = K.create('#editor_id');

        });
    </script>-->
    <script type="text/javascript">
        $("#series").change(function () {

            var v = $(this).val();
            var html = '';
            for (var i = 0; i < v; i++) {
                html += '<div class="am-g am-margin-top">';
                html += '<div class="am-u-sm-2 am-u-md-2 am-text-right">';
                html += '第' + (i + 1) + '集';
                html += '</div>';

                html += '<div class="am-u-sm-8 am-u-md-4">';
                html += '<input type="text" class="am-input-sm" name="urls[]">';
                html += '</div>';
                html += '<div class="am-hide-sm-only am-u-md-6">';
                html += '</div>';

                html += ' </div>'

            };
            $("#html").html(html);


        });

    </script>

    <!--<script type="text/javascript">
             $("#series").change(function () {

                    var v= $(this).val();
                    var html='';
                    for (var i = 0; i <v; i++) {
                         html += '<div class="am-g am-margin-top">';
                            html +='<div class="am-u-sm-2 am-u-md-2 am-text-right">';
                                html +='第'+(i+1)+'集';
                            html +='</div>';

                            html +='<div class="am-u-sm-8 am-u-md-4">';
                                html +='<input type="text" class="am-input-sm" name="urls[]">';
                            html +='</div>';
                            html +='<div class="am-hide-sm-only am-u-md-6">';
                            html +='</div>';

                        html += ' </div>'

                    };
                    $("#html").html(html);
                    

             });

    </script>-->

    <!-- 百度编辑器 -->

    <!-- 配置文件 -->
    <script type="text/javascript" src="/assets/xSystem/vendor/ueditor/ueditor.config.js"></script>
    <!-- 编辑器源码文件 -->
    <script type="text/javascript" src="/assets/xSystem/vendor/ueditor/ueditor.all.js"></script>
    <!-- 实例化编辑器 -->
    <script type="text/javascript">
        var ue = new UE.ui.Editor({initialFrameHeight: 400});
        ue.render("container");
    </script>

@endsection
